<?php

use swap\loader;
use swap\service_except;

class mail_service extends swap\service {

    public static function send_email($to, $subject, $content) {
        loader::load_third('phpmailer/class.phpmailer.php');
        
        $mail = new PHPMailer(true);
        $mail->IsSMTP();
        try {
            $mail->SMTPAuth = true;
            $mail->Host = "smtp.qq.com";
            $mail->Username = "fzrlnet@qq.com";
            $mail->Password = "hinson_0932";
            $mail->SetFrom('fzrlnet@qq.com', '抚州人力资源网');
            $mail->AddAddress($to, strstr($to, '@', true));
            $mail->Subject = $subject;
            $mail->MsgHTML($content);
            $mail->Send();
        } catch (phpmailerException $e) {
            service_except::throw_prop_msg('email', $e->errorMessage());
        }
    }
    
    public static function get_mail_captcha() {
        return rand(100000, 999999);
    }

}